package com.squareup.picasso;

import android.graphics.Bitmap.Config;
import android.net.Uri;

import com.ss.android.article.browser.R;
import com.ss.android.image.Image;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import inline.ScreenshotListener;

public final class Request {
    public static final class Builder {
        int width;
        int height;
        Picasso.Priority priority;
        Image image;
        private Uri uri;
        private int resourceId;
        private String stableKey;
        private boolean centerCrop;
        private boolean centerInside;
        private boolean j;
        private float rotationDegrees;
        private float rotationPivotX;
        private float rotationPivotY;
        private boolean hasRotationPivot;
        private List transformations;
        private Config config;

        public Builder() {
            this.resourceId = R.drawable.big_defaulthead_head;
            this.uri = null;
        }

        Builder(Uri uri, Config config) {
            this.uri = uri;
            this.resourceId = 0;
            this.config = config;
        }

        Builder(Request request) {
            this.uri = request.uri;
            this.resourceId = request.resourceId;
            this.stableKey = request.stableKey;
            this.width = request.targetWidth;
            this.height = request.targetHeight;
            this.centerCrop = request.centerCrop;
            this.centerInside = request.centerInside;
            this.rotationDegrees = request.rotationDegrees;
            this.rotationPivotX = request.rotationPivotX;
            this.rotationPivotY = request.rotationPivotY;
            this.hasRotationPivot = request.hasRotationPivot;
            this.j = request.l;
            if (request.transformations != null) {
                this.transformations = new ArrayList(request.transformations);
            }

            this.config = request.config;
            this.priority = request.priority;
        }

        final boolean hasImage() {
            return this.uri != null || this.resourceId != 0;
        }

        public final Request build() {
            if ((this.centerInside) && (this.centerCrop)) {
                throw new IllegalStateException("Center crop and center inside can not be used together.");
            }

            if ((this.centerCrop) && this.width == 0 && this.height == 0) {
                throw new IllegalStateException("Center crop requires calling resize with positive width and height.");
            }

            if ((this.centerInside) && this.width == 0 && this.height == 0) {
                throw new IllegalStateException("Center inside requires calling resize with positive width and height.");
            }
            if (this.priority == null) {
                this.priority = Picasso.Priority.NORMAL;
            }
            return new Request(this.uri, this.resourceId, this.stableKey, this.transformations, this.width, this.height, this.centerCrop, this.centerInside, this.j, this.rotationDegrees, this.rotationPivotX, this.rotationPivotY, this.hasRotationPivot, this.config, this.priority, this.image);
        }
    }

    int id;
    long started;
    int networkPolicy;
    public final Uri uri;
    public final int resourceId;
    public final String stableKey;
    public final List<ScreenshotListener> transformations;
    public final int targetWidth;
    public final int targetHeight;
    public final boolean centerCrop;
    public final boolean centerInside;
    public final boolean l;
    public final float rotationDegrees;
    public final float rotationPivotX;
    public final float rotationPivotY;
    public final boolean hasRotationPivot;
    public final Config config;
    public final Picasso.Priority priority;
    public final Image image;

    private Request(Uri uri, int resourceId, String stableKey,
                    List transformations, int width, int height,
                    boolean centerCrop, boolean centerInside, boolean arg11,
                    float rotationDegrees, float rotationPivotX, float rotationPivotY,
                    boolean hasRotationPivot, Config config,
                    Picasso.Priority priority, Image image) {
        this.uri = uri;
        this.resourceId = resourceId;
        this.stableKey = stableKey;
        this.transformations = transformations == null ? null : Collections.unmodifiableList(transformations);
        this.targetWidth = width;
        this.targetHeight = height;
        this.centerCrop = centerCrop;
        this.centerInside = centerInside;
        this.l = arg11;
        this.rotationDegrees = rotationDegrees;
        this.rotationPivotX = rotationPivotX;
        this.rotationPivotY = rotationPivotY;
        this.hasRotationPivot = hasRotationPivot;
        this.config = config;
        this.priority = priority;
        this.image = image;
    }

    public final boolean hasSize() {
        return this.targetWidth != 0 || this.targetHeight != 0;
    }

    final boolean needsMatrixTransform() {
        return (this.hasSize()) || this.rotationDegrees != 0f;
    }

    final boolean hasCustomTransformations() {
        return this.transformations != null;
    }

    public final String toString() {
        char v6 = ',';
        char v5 = ' ';
        char v4 = ')';
        StringBuilder v1 = new StringBuilder("Request{");
        if (this.resourceId > 0) {
            v1.append(this.resourceId);
        } else {
            v1.append(this.uri);
        }

        if (this.transformations != null && !this.transformations.isEmpty()) {
            Iterator<ScreenshotListener> v2 = this.transformations.iterator();
            while (v2.hasNext()) {
                v1.append(v5).append(v2.next().key());
            }
        }

        if (this.stableKey != null) {
            v1.append(" stableKey(").append(this.stableKey).append(v4);
        }

        if (this.targetWidth > 0) {
            v1.append(" resize(").append(this.targetWidth).append(v6).append(this.targetHeight).append(v4);
        }

        if (this.centerCrop) {
            v1.append(" centerCrop");
        }

        if (this.centerInside) {
            v1.append(" centerInside");
        }

        if (this.rotationDegrees != 0f) {
            v1.append(" rotation(").append(this.rotationDegrees);
            if (this.hasRotationPivot) {
                v1.append(" @ ").append(this.rotationPivotX).append(v6).append(this.rotationPivotY);
            }

            v1.append(v4);
        }

        if (this.config != null) {
            v1.append(v5).append(this.config);
        }

        v1.append('}');
        return v1.toString();
    }
}

